/**
 * 
 */
package tests;
import domain.*;

import java.util.*;

/**
 * @author it-equipment-selection team
 *
 */
public class ConsultProductTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		User u1 = new User("tecnico","antonio","antpasswd","Antonio Sanchez");
		Store.getInstance().setUserProfile(u1);
		Collection c = Store.getInstance().performQuery(Store.getInstance().getProducts(), Store.getInstance().getArticles());
		System.out.println("Consulta de productos para un usuario con perfil: " + u1.getProfile());
		Iterator it = c.iterator();
		while (it.hasNext()){
			Product p = (Product) it.next();
			System.out.println(p.getBrand() + " " + p.getModel() + " not validate yet" + " (validate = " + p.isValidate() + ")");
		}
		
		User u2 = new User("licitador","antonio","antpasswd","Antonio Sanchez");
		Store.getInstance().setUserProfile(u2);
		c = Store.getInstance().performQuery(Store.getInstance().getProducts(), Store.getInstance().getArticles());
		System.out.println();
		System.out.println("Consulta de productos para un usuario con perfil: " + u2.getProfile());
		it = c.iterator();
		while (it.hasNext()){
			Product p = (Product) it.next();
			p.doValidate();
			System.out.println("Licitador: " + p.getSupplier().getBidderCode() + " Producto: " + p.getBrand() + " " + p.getModel() + " Es válido? " + p.isValid());
		}
		
		User u3 = new User("mesa","antonio","antpasswd","Antonio Sanchez");
		Store.getInstance().setUserProfile(u3);
		c = Store.getInstance().performQuery(Store.getInstance().getProducts(), Store.getInstance().getArticles());
		System.out.println();
		System.out.println("Consulta de productos para un usuario con perfil: " + u3.getProfile());
		it = c.iterator();
		while (it.hasNext()){
			Product p = (Product) it.next();
			System.out.println("Artículo: " + p.getArticle().getType() + " Producto: " + p.getBrand() + " " + p.getModel() + " Número de votos: " + p.getNumVotes());
		}
		
		User u4 = new User("usuario","antonio","antpasswd","Antonio Sanchez");
		Store.getInstance().setUserProfile(u4);
		c = Store.getInstance().performQuery(Store.getInstance().getProducts(), Store.getInstance().getArticles());
		System.out.println();
		System.out.println("Consulta de productos para un usuario con perfil: " + u4.getProfile());
		it = c.iterator();
		while (it.hasNext()){
			Product p = (Product) it.next();
			p.doValidate();
			System.out.println("Artículo: " + p.getArticle().getType() + " Producto: " + p.getBrand() + " " + p.getModel() + " Válido: " + p.isValid() + " ¡Votar! ");
		}
	}

}
